/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.admanager.piadladmanagement.plugin.piadladmanagement.impl;

import java.util.Collection;

import org.admanager.piadladmanagement.plugin.piadladmanagement.Architecture;
import org.admanager.piadladmanagement.plugin.piadladmanagement.CBAPattern;
import org.admanager.piadladmanagement.plugin.piadladmanagement.ComponentMapping;
import org.admanager.piadladmanagement.plugin.piadladmanagement.ComponentPortMapping;
import org.admanager.piadladmanagement.plugin.piadladmanagement.ConnectorMapping;
import org.admanager.piadladmanagement.plugin.piadladmanagement.ConnectorRoleMapping;
import org.admanager.piadladmanagement.plugin.piadladmanagement.MappingRoot;
import org.admanager.piadladmanagement.plugin.piadladmanagement.PiadladmanagementPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mapping Root</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.MappingRootImpl#getPiadl <em>Piadl</em>}</li>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.MappingRootImpl#getCbapattern <em>Cbapattern</em>}</li>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.MappingRootImpl#getComponentmappings <em>Componentmappings</em>}</li>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.MappingRootImpl#getConnectormappings <em>Connectormappings</em>}</li>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.MappingRootImpl#getComponentportmappings <em>Componentportmappings</em>}</li>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.MappingRootImpl#getConnectorrolemappings <em>Connectorrolemappings</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MappingRootImpl extends EObjectImpl implements MappingRoot {
	/**
	 * The cached value of the '{@link #getPiadl() <em>Piadl</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPiadl()
	 * @generated
	 * @ordered
	 */
	protected Architecture piadl;

	/**
	 * The cached value of the '{@link #getCbapattern() <em>Cbapattern</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCbapattern()
	 * @generated
	 * @ordered
	 */
	protected CBAPattern cbapattern;

	/**
	 * The cached value of the '{@link #getComponentmappings() <em>Componentmappings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComponentmappings()
	 * @generated
	 * @ordered
	 */
	protected EList componentmappings;

	/**
	 * The cached value of the '{@link #getConnectormappings() <em>Connectormappings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnectormappings()
	 * @generated
	 * @ordered
	 */
	protected EList connectormappings;

	/**
	 * The cached value of the '{@link #getComponentportmappings() <em>Componentportmappings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComponentportmappings()
	 * @generated
	 * @ordered
	 */
	protected EList componentportmappings;

	/**
	 * The cached value of the '{@link #getConnectorrolemappings() <em>Connectorrolemappings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnectorrolemappings()
	 * @generated
	 * @ordered
	 */
	protected EList connectorrolemappings;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MappingRootImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return PiadladmanagementPackage.Literals.MAPPING_ROOT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Architecture getPiadl() {
		return piadl;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPiadl(Architecture newPiadl, NotificationChain msgs) {
		Architecture oldPiadl = piadl;
		piadl = newPiadl;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PiadladmanagementPackage.MAPPING_ROOT__PIADL, oldPiadl, newPiadl);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPiadl(Architecture newPiadl) {
		if (newPiadl != piadl) {
			NotificationChain msgs = null;
			if (piadl != null)
				msgs = ((InternalEObject)piadl).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PiadladmanagementPackage.MAPPING_ROOT__PIADL, null, msgs);
			if (newPiadl != null)
				msgs = ((InternalEObject)newPiadl).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PiadladmanagementPackage.MAPPING_ROOT__PIADL, null, msgs);
			msgs = basicSetPiadl(newPiadl, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PiadladmanagementPackage.MAPPING_ROOT__PIADL, newPiadl, newPiadl));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CBAPattern getCbapattern() {
		return cbapattern;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCbapattern(CBAPattern newCbapattern, NotificationChain msgs) {
		CBAPattern oldCbapattern = cbapattern;
		cbapattern = newCbapattern;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN, oldCbapattern, newCbapattern);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCbapattern(CBAPattern newCbapattern) {
		if (newCbapattern != cbapattern) {
			NotificationChain msgs = null;
			if (cbapattern != null)
				msgs = ((InternalEObject)cbapattern).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN, null, msgs);
			if (newCbapattern != null)
				msgs = ((InternalEObject)newCbapattern).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN, null, msgs);
			msgs = basicSetCbapattern(newCbapattern, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN, newCbapattern, newCbapattern));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getComponentmappings() {
		if (componentmappings == null) {
			componentmappings = new EObjectContainmentEList(ComponentMapping.class, this, PiadladmanagementPackage.MAPPING_ROOT__COMPONENTMAPPINGS);
		}
		return componentmappings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getConnectormappings() {
		if (connectormappings == null) {
			connectormappings = new EObjectContainmentEList(ConnectorMapping.class, this, PiadladmanagementPackage.MAPPING_ROOT__CONNECTORMAPPINGS);
		}
		return connectormappings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getComponentportmappings() {
		if (componentportmappings == null) {
			componentportmappings = new EObjectContainmentEList(ComponentPortMapping.class, this, PiadladmanagementPackage.MAPPING_ROOT__COMPONENTPORTMAPPINGS);
		}
		return componentportmappings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getConnectorrolemappings() {
		if (connectorrolemappings == null) {
			connectorrolemappings = new EObjectContainmentEList(ConnectorRoleMapping.class, this, PiadladmanagementPackage.MAPPING_ROOT__CONNECTORROLEMAPPINGS);
		}
		return connectorrolemappings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case PiadladmanagementPackage.MAPPING_ROOT__PIADL:
				return basicSetPiadl(null, msgs);
			case PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN:
				return basicSetCbapattern(null, msgs);
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTMAPPINGS:
				return ((InternalEList)getComponentmappings()).basicRemove(otherEnd, msgs);
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORMAPPINGS:
				return ((InternalEList)getConnectormappings()).basicRemove(otherEnd, msgs);
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTPORTMAPPINGS:
				return ((InternalEList)getComponentportmappings()).basicRemove(otherEnd, msgs);
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORROLEMAPPINGS:
				return ((InternalEList)getConnectorrolemappings()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PiadladmanagementPackage.MAPPING_ROOT__PIADL:
				return getPiadl();
			case PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN:
				return getCbapattern();
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTMAPPINGS:
				return getComponentmappings();
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORMAPPINGS:
				return getConnectormappings();
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTPORTMAPPINGS:
				return getComponentportmappings();
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORROLEMAPPINGS:
				return getConnectorrolemappings();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PiadladmanagementPackage.MAPPING_ROOT__PIADL:
				setPiadl((Architecture)newValue);
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN:
				setCbapattern((CBAPattern)newValue);
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTMAPPINGS:
				getComponentmappings().clear();
				getComponentmappings().addAll((Collection)newValue);
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORMAPPINGS:
				getConnectormappings().clear();
				getConnectormappings().addAll((Collection)newValue);
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTPORTMAPPINGS:
				getComponentportmappings().clear();
				getComponentportmappings().addAll((Collection)newValue);
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORROLEMAPPINGS:
				getConnectorrolemappings().clear();
				getConnectorrolemappings().addAll((Collection)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case PiadladmanagementPackage.MAPPING_ROOT__PIADL:
				setPiadl((Architecture)null);
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN:
				setCbapattern((CBAPattern)null);
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTMAPPINGS:
				getComponentmappings().clear();
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORMAPPINGS:
				getConnectormappings().clear();
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTPORTMAPPINGS:
				getComponentportmappings().clear();
				return;
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORROLEMAPPINGS:
				getConnectorrolemappings().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PiadladmanagementPackage.MAPPING_ROOT__PIADL:
				return piadl != null;
			case PiadladmanagementPackage.MAPPING_ROOT__CBAPATTERN:
				return cbapattern != null;
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTMAPPINGS:
				return componentmappings != null && !componentmappings.isEmpty();
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORMAPPINGS:
				return connectormappings != null && !connectormappings.isEmpty();
			case PiadladmanagementPackage.MAPPING_ROOT__COMPONENTPORTMAPPINGS:
				return componentportmappings != null && !componentportmappings.isEmpty();
			case PiadladmanagementPackage.MAPPING_ROOT__CONNECTORROLEMAPPINGS:
				return connectorrolemappings != null && !connectorrolemappings.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //MappingRootImpl
